package logic

import (
	"context"

	domain "go-weixin/app/diary/rpc/internal/doamin"
	"go-weixin/app/diary/rpc/internal/svc"
	"go-weixin/app/diary/rpc/pb/proto/diary"

	"github.com/zeromicro/go-zero/core/logx"
)

type DiaryDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
	diaryDomain *domain.DiaryDomain
}

func NewDiaryDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DiaryDeleteLogic {
	return &DiaryDeleteLogic{
		ctx:         ctx,
		svcCtx:      svcCtx,
		Logger:      logx.WithContext(ctx),
		diaryDomain: domain.NewDiaryDomain(*svcCtx.ChenDb),
	}
}

func (l *DiaryDeleteLogic) DiaryDelete(in *diary.DiaryDeleteReq) (*diary.DiaryDeleteResp, error) {
	err := l.diaryDomain.DiaryDelete(in.Id)
	if err != nil {
		return nil, err
	}
	return &diary.DiaryDeleteResp{}, nil
}
